<template>
  <el-dialog
    title="变更日志"
    :visible.sync="dialogVisible"
    width="90%"
    :close-on-click-modal="false"
  >
    <!--主列表数据-->
    <d2-crud
      ref="d2Crud"
      :options="mainTable.options"
      :index-row="mainTable.indexRow"
      :columns="mainTable.columns"
      :data="mainTable.list"
      :selection-row="mainTable.allowSelect"
      :loading="mainTable.loading"
      @selection-change=""
    ></d2-crud>

    <div slot="footer" class="dialog-footer">
      <el-button @click="close" size="small">关 闭</el-button>
    </div>

    <column-content></column-content>
  </el-dialog>
</template>

<script>

import ColumnContent from './column-content';
import ApiMain from '@/api/mch.protest';
export default {
  mixins: [
  ],
  props: [
  ],
  components: {
    ColumnContent
  },
  data() {
    return {

      dialogVisible: false,
      mainTable: {
        loading: false,
        options: {
          border: true,
          stripe: true,
          highlightCurrentRow: true,
          emptyText: '暂无数据',
          size: 'mini',
        },
        indexRow: null,
        allowSelect: false,
        columns: [
          { title: '名称', key: 'name', align: 'center', showOverflowTooltip: true },
          { title: '规则', key: 'content', align: 'center', showOverflowTooltip: true, component: {
            name: ColumnContent} },
          { title: '更新日期', key: 'updateTime', align: 'center', showOverflowTooltip: true },
          { title: '更新人', key: 'updateBy', align: 'center', showOverflowTooltip: true },
        ],
        list: [],
        pagination: {
          currentPage: 1,
          pageSize: 50,
          total: 0,
          pageSizes: [50, 100, 200]
        },
      },

    }
  },

  methods: {

    show(id = null) {

      this.id = id;

      this.fetchData();

      this.dialogVisible = true;
    },

    close() {
      this.dialogVisible = false;
      this.$emit('dialog-close');
    },

    fetchData() {
      this.mainTable.loading = true;
      ApiMain.log({ id: this.id })
        .then(re => {
          this.mainTable.loading = false;
          re.forEach((item, index) => {
            re[index]['perFee'] = item['perFee'] / 100;
            re[index]['disFee'] = item['disFee'] / 100;
            re[index]['disFineFee'] = item['disFineFee'] / 100;
            re[index]['refundFee'] = item['refundFee'] / 100;
            re[index]['refundTradeFee'] = item['refundTradeFee'] / 100;
            re[index]['refundTradeReturnFee'] = item['refundTradeReturnFee'] / 100;
            re[index]['tradeFailFee'] = item['tradeFailFee'] / 100;
            re[index]['disWarnFee'] = item['disWarnFee'] / 100;
          })
          this.mainTable.list = re;
        })
    }

  }

}
</script>
